package com.jdk8.demo;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Java8_Stream_Peek {
	
	public static void main(String[] args) throws IOException {

		Stream.of("one", "two", "three", "four")
	    .peek(e -> System.out.println("Peeked value: " + e))
	    .map(String::toUpperCase)
	    .peek(e -> System.out.println("Mapped value: " + e))
	    .collect(Collectors.toList());
		
		
		
		
		
		
		List<String> nations = Arrays.asList("A","B","C","A1");
        nations.stream().
        filter(nation -> {
            return nation.startsWith("A"); 
        }).
        peek(nation -> System.out.println(nation)).
        map((t) ->  {
            return t + "a";
        }).
        peek(nation -> System.out.println(nation)).
        collect(Collectors.toList());
		
	}

}
